<!--  -->
<template>
  <div class>
    <div class="serviceW">
      <h1>修改资料</h1>
      <section class="serviceBox">
        <div class="serviceTop">请填写密码信息</div>
        <div class="serviceBom">
          <p>
            <span>
              员工姓名
              <i>*</i>：
            </span>
            <input type="text" v-model="name" />
          </p>
          <p>
            <span>
              工号
              <i>*</i>：
            </span>
            <em>{{staffIDdata}}</em>
          </p>
          <p>
            <span>
              原密码
              <i>*</i>：
            </span>
            <input type="password" class="inp2" PasswordChar="*" v-model="PassW" />
          </p>
          <p>
            <span>
              新密码
              <i>*</i>：
            </span>
            <input type="text" v-model="oldPassW" class="inp1" placeholder="请输入6位以上的密码，数字或英文" />
          </p>
          <p>
            <span>
              确认新密码
              <i>*</i>：
            </span>
            <input type="text" v-model="newPassW" class="inp1" placeholder="请再输入一次密码" />
          </p>
          <section @click="open" class="serviceBtn" :plain="true">
            <i class="el-icon-document-remove"></i>
            <router-link to="/essay">保存</router-link>
          </section>
        </div>
      </section>
    </div>
  </div>
</template>

<script>

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      name: "",
      PassW: "",
      oldPassW: "",
      newPassW: "",
      staffIDdata:'',
      ypass:'',
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    open: function () {
       this.$message({
        message: "保存成功！",
        type: "success",
      });
      this.$router.push({path:'/essay'})

    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    let text = document.cookie
    
    // 筛选
    text =text.split(';')
    for(let i in text){
        //断开去除空格
        let arrnoe = text[i].split('=')
        let str = arrnoe[0].replace(/\s*/g,"")
         if(str=='fxjy'){
           this.$axios.get('data/login.json').then((res)=>{
             let ygIndex = res.findIndex(itme=>{
               return itme.id==arrnoe[1]
             })
            this.name = res[ygIndex].user 
            this.staffIDdata = res[ygIndex].staffID
            this.PassW = res[ygIndex].pass
            this.ypass = res[ygIndex].pass
           })
         }
    }
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style  scoped>
a {
  text-decoration: none;
  color: #fff;
}
input {
  outline: none;
}
i,
em {
  font-style: normal;
}
.serviceW {
  width: 1100px;
  margin: 0 auto;
  color: #333;
  font-size: 14px;
}
h1 {
  height: 70px;
  line-height: 70px;
  font-family: "思源黑体 Bold", "思源黑体 Regular", "思源黑体";
  font-weight: 700;
  font-style: normal;
  font-size: 24px;
  color: #9137f3;
}
.serviceBox {
  border: 1px solid #e4e4e4;
  padding: 15px 30px;
  min-height: 598px;
}
.serviceTop {
  height: 35px;
  color: #999;
  border-bottom: 1px solid #e4e4e4;
  line-height: 20px;
}
.serviceBom {
  margin-top: 90px;
}

.serviceBom p {
  height: 40px;
  margin-bottom: 25px;
}
.serviceBom p span {
  display: inline-block;
  width: 125px;
  text-align: right;
  line-height: 38px;
}
.serviceBom p span i {
  color: red;
}
.serviceBom p input {
  line-height: 38px;
  padding: 0 10px;
  height: 38px;
  border: 1px solid #e4e4e4;
  border-radius: 0.2em;
}
.serviceBom p em {
  font-size: 12px;
}
.serviceBtn {
  width: 98px;
  height: 36px;
  background: #9137f3;
  color: #fff;
  line-height: 36px;
  text-align: center;
  margin: 0 auto;
  border-radius: 0.2em;
  margin-top: 122px;
}
.inp1,
.inp2 {
  color: #999;
  font-size: 12px;
  width: 275px;
}
.inp2 {
  color: #333;
  font-size: 24px;
  font-weight: 400px;
  line-height: 38px;
}
</style>